#ifndef MYTCPSOCKET_H
#define MYTCPSOCKET_H

#include <QTcpSocket>
class SqlExec;
class MyThread;

class MyTcpSocket : public QTcpSocket {
  Q_OBJECT
public:
  explicit MyTcpSocket(QObject *parent = nullptr);
  void setDB(SqlExec *db);

signals:
  void socketDisconnected(MyThread *th);
  void sendData(QByteArray data);

public slots:
  void sendDataSlot(QByteArray data);

protected slots:
  /**
   * @brief 读取客户端或者网关发来的数据帧
   */
  void readyReadSlot();
  void disconnectedSlot(); //捕获断开信息

protected:
  void handleData(QByteArray data);
  /**
   * @brief 处理接收到的数据帧
   * @param data
   */
  void handleFrame(QByteArray data);
  QByteArray temp;
  SqlExec *_db;
};

#endif // MYTCPSOCKET_H
